/**
 * Http Response
 */
class Response {
  /**
   * constructor
   * @param {Object<body>} body
   * @param {Object<headers>} headers
   * @param {Integer} statusCode
   */
  constructor(body, headers = {}, statusCode = 200) {
    console.info('Response constructor', { body, headers, statusCode });

    this.statusCode = statusCode;
    this.body = JSON.stringify(body);
    this.headers = Object.assign({ 'Access-Control-Allow-Origin': '*' }, headers);
  }

  /**
   * empty payload on success
   * @return {Response} response
   */
  static success() {
    return new Response({});
  }
}

module.exports = Response;
